package daos;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import beans.MemberBean;

public class MemberDAO {
	String driver = "com.mysql.jdbc.Driver";
	String url = "jdbc:mysql://192.168.0.42:3306/kiss";
	String id = "root";
	String pw = "0000";
	private Connection conn = null;
	
	public MemberDAO() throws SQLException, ClassNotFoundException {
		try {
			Class.forName(driver);
			System.out.println("Success");
		} catch(Exception e) {
			 System.out.println("Error"+e);
		}
	}
	
	public void insertStu(MemberBean memberbean) throws SQLException {
		PreparedStatement pstmt = null;

		conn = DriverManager.getConnection(url,id,pw);
		String sql = "insert into student(m_id, m_id, m_password, m_name, m_birth, m_gender) values(?, ?, ?, ?, ?)";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1,memberbean.getM_id());
			pstmt.setString(2,memberbean.getM_password());
			pstmt.setString(3,memberbean.getM_name());
			pstmt.setString(4,memberbean.getM_birth());
			pstmt.setString(5,memberbean.getM_gender());
			
			pstmt.executeUpdate();
			pstmt.close();
	}
	
	public void close() throws SQLException {
		if(conn!=null) 
			conn.close();
	}
}